/**
 * LVL.Arena - Ground, borders and scenery.
 */

define(['blacksmith/game', 'lvl/config'], function() {



/**
 * Constructs an LVL.Arena instance.
 * 
 * @param {object} args
 * @constructor
 * @extends GAME.Block
 */
LVL.Arena = function(args) {
    
    args = args || {}
    args.name = args.name || 'GROUND'
    args.width = CONFIG.arenaSize
    args.height = 0.000000001
    args.depth = CONFIG.arenaSize
    args.colour = 0x666666
    args.mass = 0
    args.shape = new CANNON.Plane(new CANNON.Vec3(0,1,0))
    
    GAME.Block.call(this, args)
    GAME.add(this)
    GAME.ActiveRootBlocks.push(this)
    
    
    var r = (CONFIG.arenaSize * 0.5) + 30,
        a,
        x,
        z,
        b,
        s = 0.15
    
    for (a = -Math.PI; a < Math.PI; a += s) {
        x = r * Math.cos(a+(s*0.5))
        z = r * Math.sin(a+(s*0.5))
        
        GAME.add(new GAME.Block({
            name   : 'perimeter',
            x      : x,
            y      : 140,
            z      : z,
            angle  : -a-(s*0.5),
            width  : 160,
            depth  : 80,
            height : 40,
            colour : 0x555555,
            mass   : 0
        }))
        
        x = r * Math.cos(a)
        z = r * Math.sin(a)
        
        GAME.add(new GAME.Block({
            name   : 'perimeter',
            x      : x,
            y      : 70,
            z      : z,
            angle  : -a,
            width  : 150,
            depth  : s * r,
            height : 150,
            colour : 0x666666,
            mass   : 0
        }))
    }
    
}


LVL.Arena.prototype = Object.create(GAME.Block.prototype)


/**
 * Updates component state.
 */
LVL.Arena.prototype.update = function() {
    
    GAME.Block.prototype.update.call(this)
    
    
}


})